
package efg;
public class stacklist implements List {
    private Object data[];
    private int top;
    
    public stacklist(){
        this.data=new Object[1000];
        this.top=0;
    }
    public boolean isEmpty(){
        return top==0;
    }
    public void push(Object o){
        if(this.top>1000)
            throw new ArrayIndexOutOfBoundsException("长度超过最大值，栈溢出.");
        else
           this.data[top++]=o;
    }
    public Object pop(){
        if(top<=0)
            throw new ArrayIndexOutOfBoundsException("已经到达栈底");
        else
         return this.data[--this.top];
    }
    public Object getTop(){
        if(this.top==0)
            throw new ArrayIndexOutOfBoundsException("已经到栈底");
        return this.data[this.top-1];
    }
  
}
